//
//  ConsultingViewController.m
//  WE
//
//  Created by 要帅气的生活 on 15/11/28.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "ConsultingViewController.h"
#import "BaseView.h"
#import "Size.h"
#import "ConsultingView.h"
#import "SingletonStoreSimpleData.h"

static BOOL zhuangtai;
@interface ConsultingViewController ()
@property (nonatomic,strong) UILabel *label;
@property (nonatomic,strong) NSMutableArray *arr;
@property (nonatomic,strong) UIView *optionsView;
@property (nonatomic,strong) BaseView *viewBase;
@end

@implementation ConsultingViewController
- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
    zhuangtai = YES;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [SingletonStoreSimpleData shareViewController].state = YES;
    
    _arr = @[].mutableCopy;
    
    _viewBase = [[BaseView alloc] initWithFrame:CGRectMake(0, 0, WindowWidth, WindowHeight)];
    _viewBase.backgroundColor = GRAYCOLOR;
    [self.view addSubview:_viewBase];
    [_viewBase addTarget:self selector:@selector(fanhui)];
    [self options];
    
    BaseView *baseview = [[BaseView alloc] initWithFrame:CGRectMake(0, 0, 120, 40)];
    _label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 105, 40)];
    [baseview addSubview:_label];
    _label.text = [NSString stringWithFormat:@"全部咨询(%ld)",_arr.count];
    _label.textAlignment = 1;
    
    UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(105, 12.5, 15, 15)];
    img.image = [UIImage imageNamed:@"arrow_bottom.png"];
    [baseview addSubview:img];
    
    self.navigationItem.titleView = baseview;
    [baseview addTarget:self selector:@selector(consulting)];
    
}

-(void)options{
    _optionsView = [[UIView alloc] initWithFrame:CGRectMake(WindowWidth/4, 64, WindowWidth/2, 200)];
    [_viewBase addSubview:_optionsView];
    _optionsView.alpha = 0;
    NSArray *name = @[@"全部咨询",@"图文咨询",@"电话咨询",@"视频咨询"];
    for (int i = 0; i<4; i++) {
        ConsultingView *consulting = [[ConsultingView alloc] initWithFrame:CGRectMake(0, i*_optionsView.frame.size.height/4, _optionsView.frame.size.width, _optionsView.frame.size.height/4)];
        [_optionsView addSubview:consulting];
        consulting.titleLbl.text = name[i];
        consulting.tag = 130+i;
        [consulting addTarget:self selector:@selector(consuView:)];
    }
}

-(void)consuView:(ConsultingView *)view{
    if (view.tag == 130) {
        NSLog(@"1");
        _label.text = [NSString stringWithFormat:@"%@(%ld)", view.titleLbl.text,_arr.count];
        _optionsView.alpha = 0;
        zhuangtai = YES;
    }
    if (view.tag == 131) {
        NSLog(@"2");
        _label.text = [NSString stringWithFormat:@"%@(%ld)", view.titleLbl.text,_arr.count];
        _optionsView.alpha = 0;
        zhuangtai = YES;
    }
    if (view.tag == 132) {
        NSLog(@"3");
        _label.text = [NSString stringWithFormat:@"%@(%ld)", view.titleLbl.text,_arr.count];
        _optionsView.alpha = 0;
        zhuangtai = YES;
    }
    if (view.tag == 133) {
        NSLog(@"4");
        _label.text = [NSString stringWithFormat:@"%@(%ld)", view.titleLbl.text,_arr.count];
        _optionsView.alpha = 0;
        zhuangtai = YES;
    }
}

-(void)consulting{
    
    if (zhuangtai == YES) {
        _optionsView.alpha = 1;
        zhuangtai = NO;
    }else{
        _optionsView.alpha = 0;
        zhuangtai = YES;
    }
}

-(void)fanhui{
    zhuangtai = YES;
    _optionsView.alpha = 0;
}
@end
